﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cz.zcu.PreSti.Shapes;
using Dataweb.NShape;

namespace cz.zcu.PreSti.Guide
{
    /// <summary>
    /// Provides creator of particular symbols
    /// </summary>
    public class SymbolsCreater
    {
        private Project project;
        private Template template;
        private Shape shape;
        private TemplatesShape item;

        /// <summary>
        /// Initializes a new instance of the <see cref="SymbolsCreater"/> class.
        /// </summary>
        /// <param name="project">The project.</param>
        public SymbolsCreater(Project project)
        {
            this.project = project;
        }

        /// <summary>
        /// Adds the connector.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddConnector()
        {
            template = project.Repository.GetTemplate("Connector");
            shape = template.CreateShape();
            item = new TemplatesShape(shape, "Connector");
            return item;
        }

        /// <summary>
        /// Adds the trigger.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddTrigger()
        {
            template = project.Repository.GetTemplate("Trigger");
            shape = template.CreateShape();
            TriggerModel model = (TriggerModel)shape.ModelObject;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Trigger");
            return item;
        }

        /// <summary>
        /// Adds the discrete generator item.
        /// </summary>
        /// <param name="probability">The probability.</param>
        /// <param name="value">The value.</param>
        /// <returns>TemplatesShape</returns>
        public DiscreteGeneratorModel.DiscreteGeneratorPossibility AddDiscreteGeneratorItem(float probability, String value)
        {
            DiscreteGeneratorModel.DiscreteGeneratorPossibility possibilityItem = new DiscreteGeneratorModel.DiscreteGeneratorPossibility();
            possibilityItem.Probability = probability;
            possibilityItem.Value = value;

            return possibilityItem;
        }

        /// <summary>
        /// Adds the text stimulus.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddTextStimulus()
        {
            template = project.Repository.GetTemplate("TextStimulus");
            shape = template.CreateShape();
            TextStimulusModel model = (TextStimulusModel)shape.ModelObject;
            model.Text = "Hello word";
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Text");

            return item;

        }

        /// <summary>
        /// Adds the sound stimulus.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddSoundStimulus()
        {
            template = project.Repository.GetTemplate("SoundStimulus");
            shape = template.CreateShape();
            SoundStimulusModel model = (SoundStimulusModel)shape.ModelObject;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Sound");

            return item;

        }

        /// <summary>
        /// Adds the image stimulus.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddImageStimulus()
        {
            template = project.Repository.GetTemplate("ImageStimulus");
            shape = template.CreateShape();
            ImageStimulusModel model = (ImageStimulusModel)shape.ModelObject;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Image");

            return item;

        }

        /// <summary>
        /// Adds the entry point.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddEntryPoint()
        {
            template = project.Repository.GetTemplate("EntryPoint");
            shape = template.CreateShape();
            shape.X = 300;
            shape.Y = 400;
            item = new TemplatesShape(shape, "EntryPoint");
            return item;
        }

        /// <summary>
        /// Adds the repeater.
        /// </summary>
        /// <param name="repetitionNumber">The repetition number.</param>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddRepeater(int repetitionNumber)
        {
            template = project.Repository.GetTemplate("Repeater");
            shape = template.CreateShape();
            RepeaterModel model = (RepeaterModel)shape.ModelObject;
            model.RepetitionRate = repetitionNumber;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Repeater");
            return item;
        }

        /// <summary>
        /// Adds the splitter.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddSplitter()
        {
            template = project.Repository.GetTemplate("Splitter");
            shape = template.CreateShape();
            SplitterModel model = (SplitterModel)shape.ModelObject;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "Splitter");
            return item;
        }

        /// <summary>
        /// Adds the discrete generator.
        /// </summary>
        /// <returns>TemplatesShape</returns>
        public TemplatesShape AddDiscreteGenerator()
        {
            template = project.Repository.GetTemplate("DiscreteGenerator");
            shape = template.CreateShape();
            DiscreteGeneratorModel model = (DiscreteGeneratorModel)shape.ModelObject;
            shape.X = 400;
            shape.Y = 400;
            item = new TemplatesShape(shape, model, "DiscreteGenerator");
            return item;
        }
    }
}
